import requests
import json

url = "https://api.cntv.cn/list/getVideoAlbumList"
get_param = {
    "channelid": "CHAL1460955853485115", "area": "", "sc": "", "fc": "电视剧", "year": "", "letter": "", "p": "1",
    "n": "1180", "serviceId": "tvcctv", "topv": "1", "t": "jsonp", "cb": "Callback"
}
UA = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"}
index = 1
list_all = []
all_title = []
while index < 13:
    response = requests.get(url=url, params=get_param, headers=UA)
    fp = open(f'./111.json', 'w', encoding='utf-8')
    new_obj = json.loads(response.text.replace('Callback(', '').replace(');', ''))
    list_item = new_obj['data']['list']
    list_all.extend(list_item)
    index += 1
    get_param['p'] = index
for item in list_all:
    all_title.extend(item['title'])
json.dump(list_all, fp=fp, ensure_ascii=False)
fp.close()
print(len(list_all))
print('over')




